//
//  SCPhotoAlbumSectionHeader.m
//  PhotoAlbum
//
//  Created by Chao Sheng on 2021/12/3.
//

#import "SCPhotoAlbumSectionHeader.h"

@interface SCPhotoAlbumSectionFooter ()

@property (nonatomic, strong)  UILabel *countLabel;

@end

@implementation SCPhotoAlbumSectionFooter

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

- (void)setPhotoCount:(NSInteger)photoCount {
    _photoCount = photoCount;
    self.countLabel.text = [NSString stringWithFormat:@"%ld 张照片",self.photoCount];
}

- (void)setupUI {
    [self addSubview:self.countLabel];
    [self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsZero);
    }];
}

#pragma mark - 懒加载
- (UILabel *)countLabel {
    if (!_countLabel) {
        _countLabel = [[UILabel alloc] init];
        _countLabel.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:15];
        _countLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _countLabel;
}

@end


@interface SCPhotoAlbumSectionHeader ()

@property (nonatomic, strong)  UILabel *dateLabel;

@property (nonatomic, strong) UIToolbar *toolBar;

@end

@implementation SCPhotoAlbumSectionHeader

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    [self addSubview:self.toolBar];
    [self.toolBar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsZero);
    }];
    [self addSubview:self.dateLabel];
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@8);
        make.centerY.equalTo(self);
    }];
}

- (void)setDateStr:(NSString *)dateStr {
    _dateStr = dateStr;
    self.dateLabel.text = _dateStr;
}

- (void)setTranslucent:(BOOL)translucent {
    _translucent = translucent;
    if (_translucent) {
        self.toolBar.barTintColor = nil;
    } else {
        self.toolBar.barTintColor = UIColor.whiteColor;
    }
}

#pragma mark - 懒加载
- (UILabel *)dateLabel {
    if (!_dateLabel) {
        _dateLabel = [[UILabel alloc] init];
        _dateLabel.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:15];
    }
    return _dateLabel;
}

- (UIToolbar *)toolBar {
    if (!_toolBar) {
        _toolBar = [[UIToolbar alloc] init];
        _toolBar.translucent = true;
        _toolBar.clipsToBounds = true;
        _toolBar.barTintColor = UIColor.whiteColor;
    }
    return _toolBar;
}

@end
